<?php
/**
 * Created by PhpStorm.
 * User: lcz
 * Date: 2018/8/24
 * Time: 9:23
 * 统计
 */

namespace app\admin\controller;

use app\common\controller\Backend;
use think\Db;

class Count extends Backend {
	
	/**
	 * 用户统计
	 * @return string
	 * @throws \think\Exception
	 */
	public function user() {
		$rows = Db::name('countUser')
			->field('time as date, all, new')
			->order(['time' => 'DESC'])
			->limit(20)
			->select();
		
		$date = '';
		$all = '';
		$new = '';
		if($rows) {
			foreach($rows as $vo) {
				$date.= '"'.date('m-d',$vo['date']).'",';
				$all .= $vo['all'].',';
				$new .= $vo['new'].',';
			}
		}
		
		
		return $this->view->fetch('user', [
			'rows' => $rows,
			'date' => $date,
			'all' => $all,
			'new' => $new
		]);
	}
}
